jQuery(function ($) {


    function del(id) {
        if (confirm("确定要删除吗？")) {
            $.ajax({
                type: "GET",
                url: "/sys/train/delete",
                data: {id: id},
                dataType: "text",
                success: function (data) {
                    if (data == "true") {
                        alert("删除成功!");
                        window.location.href = "/sys/train/trainShow";
                    }
                },
                error: function (data) {
                    alert("异常!");
                }
            });
        }
    }

    window.del = del;


    $("#add").click(function () {
        window.location.href = "/sys/train/add";
    });

    var auditStatus = $("#auditStatus");
    $.ajax({
        type: "GET",
        url: "/sys/train/trainStatus",
        dataType: "json",
        success: function (data) {
            if (data != null) {
                auditStatus.html("");
                var options = "<option value=\"0\">请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    options += "<option value=\"" + data[i].id + "\" >" + data[i].valueName + "</option>";
                }
                auditStatus.html(options);
            }
        },
        error: function (data) {
            alert("异常!");
        }
    });

    function changeNum(i) {
        if(i==0){
            $("#num").val(8);
        }else{
            $("#num").val(12);
        }
    }
    window.changeNum=changeNum;

    queryList($("#formIndex").get(0), 1);

});

